package thinkinginjava.container;

import java.nio.Buffer;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;

import org.apache.commons.collections.ArrayStack;

public class IntegerIterator implements Iterable<Integer>{

	@Override
	public Iterator<Integer> iterator() {
		return new IntegerItr();
	}

	private static class IntegerItr implements Iterator<Integer> {
		private static Integer[] array = new Integer[10];
		static {
			for(int i = 0; i < 10; i ++) {
				array[i] = i + 1;
			}
		}
		private int index;
		@Override
		public boolean hasNext() {
			return index < array.length;
		}

		@Override
		public Integer next() {
			return array[index ++];
		}

		@Override
		public void remove() {
			// TODO Auto-generated method stub
			
		}
		
	}
	
	public static void main(String[] args) {
		IntegerIterator itr = new IntegerIterator();
		for(Integer i : itr) {
			System.out.println(i);
		}
		System.out.println(Integer[].class.getName());
	}
	
}
